package URL;

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class CaptureScreen {
	private static int width = Toolkit.getDefaultToolkit().getScreenSize().width;
	private static int height = Toolkit.getDefaultToolkit().getScreenSize().height;

	public static void main(String[] args) {

		try {
			System.out.println(width + " " + height);
			Robot robot = new Robot();
			Rectangle r = new Rectangle(0, 0, width, height);
			BufferedImage image = robot.createScreenCapture(r);
			File file = new File("e:\\1.png");
			ImageIO.write(image, "png", file);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
